<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>
</head>
<body>
<form>
    <p><input type="text" name="username" id="username" placeholder="用户名"></p>
    <p><input type="password" name="password" id="password" placeholder="密码"></p>
    <p><input type="button" value="登录" id="btn"></p>
</form>



</body>
<script>
    $('#btn').click(function() {
        var username = $('#username').val();
        var password = $('#password').val();

        $.post('http://127.0.0.1:8000/api/auth/token/obtain/',
            {username: username, password: password},
            function(data) {
                if (data) {
                    // 拿到access存入localStorage.token，show_movie.html请求时放到请求头中
                    localStorage.token = data.access;
                    // 请求列表
                    location.href='show_movie.html'
                }
        })
    })

</script>
</html>